import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

import greenfoot.UserInfo;

public class Record
{
  private UserInfo player;
  
  public Record()
  {
    if ((UserInfo.isStorageAvailable()) && (UserInfo.getMyInfo() != null)) {
          this.player = UserInfo.getMyInfo();
        }
  }
 
  public void saveHighscore(int score)
  {
      if ((UserInfo.isStorageAvailable()) && (this.player != null) && ((score > this.player.getScore()) || (this.player.getInt(0) == 0)))
      {
          this.player.setScore(score);
          this.player.setInt(0, 1);
          this.player.store();
        }
      if ((UserInfo.isStorageAvailable()) && (this.player != null) && (score > this.player.getScore()))
      {
          this.player.setScore(score);
          this.player.setInt(0, 1);
          this.player.store();
      }
    }
}

